var mongoose=require('mongoose');
// 1.连接数据库
mongoose.connect('mongodb://127.0.0.1:27017/blog',function(err){
  if(err){
    throw err;
  }else{
    console.log('数据库连接成功！');
  }
});
// 2.定义骨架
var artSchema=new mongoose.Schema({
  title:String,
  category:String,
  author:String,
  content:String,
  time:String,
  hits:Number
});
// 3.创建模型
// var artModel=mongoose.model('article',artSchema,'article');
// 定义全局模型
global.artModel=mongoose.model('article',artSchema,'article');

// 公共连接，暴露出去
module.exports=mongoose;
